package com.heima.model.article.pojos;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.heima.model.annotation.IdEncrypt;
import lombok.Data;
import org.apache.ibatis.type.Alias;

import java.time.LocalDateTime;
import java.util.Date;
/**
 * APP收藏信息表
 */
@Data
@TableName(value = "ap_collection")
public class ApCollection {
    @TableId(value = "id", type = IdType.INPUT)
    private Integer id;

    /**
     * 实体ID
     */
    @IdEncrypt
    @TableField(value = "behavior_entry_id")
    private Integer behaviorEntryId;

    /**
     * 文章ID
     */
    @IdEncrypt
    @TableField(value = "entry_id")
    private Integer entryId;

    /**
     * 点赞内容类型
     0文章
     1动态
     */
    @TableField(value = "type")
    private Boolean type;

    /**
     * 创建时间
     */
    @TableField(value = "collection_time")
    private LocalDateTime collectionTime;

    /**
     * 发布时间
     */
    @TableField(value = "published_time")
    private LocalDateTime publishedTime;

    @TableField(value = "burst")
    @JsonIgnore
    private String burst;

    // 定义收藏内容类型的枚举
    @Alias("ApCollectionEnumType")
    public enum Type{
        ARTICLE((short)0),DYNAMIC((short)1);
        short code;
        Type(short code){
            this.code = code;
        }
        public short getCode(){
            return this.code;
        }
    }

    public boolean isCollectionArticle(){
        return (this.getType()!=null&&this.getType().equals(Type.ARTICLE));
    }
}
